<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Element Test Suite</title>

<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">     

<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
<script type="text/javascript" src="../build/event/event.js"></script>
<script type="text/javascript" src="../build/dom/dom.js"></script> 
<script type="text/javascript" src="../build/element/element-beta-min.js"></script> 
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
<script type="text/javascript" src="../build/yuitest/yuitest-beta.js"></script>

<style type="text/css">
#foo {
    background:#ccc;
    height:100px;
    width:100px;
}
</style>

<script type="text/javascript">
(function() {
    var Y = YAHOO.util,
        tool = YAHOO.tool,
        suite = new tool.TestSuite("yuisuite");

    Y.Event.onDOMReady(function() {
        var logger = new YAHOO.tool.TestLogger(null, { height: '80%' });

        var foo = new Y.Element('foo');
        var elFoo = document.getElementById('foo');

        suite.add( new tool.TestCase({
            name: 'YAHOO.util.Element',

            test_getElement: function() {
                YAHOO.util.Assert.areEqual(elFoo, foo.get('element'), 'incorrect element');
            },            

            test_setHTMLAttr: function() {
                var innerHTML = 'updated';
                foo.set('innerHTML', innerHTML);
                YAHOO.util.Assert.areEqual(innerHTML, foo.get('innerHTML'), 'incorrect innerHTML');
            },            

            test_setHTMLAttr: function() {
                var innerHTML = 'updated';
                foo.set('innerHTML', innerHTML);
                YAHOO.util.Assert.areEqual(innerHTML, foo.get('innerHTML'), 'incorrect innerHTML');
            },            

            test_onChange: function() {
                var pass = false;
                var handler = function() {
                    pass = true;
                };
                foo.on('titleChange', handler);
                foo.set('title', 'foo title');
                YAHOO.util.Assert.isTrue(pass, 'titleChange event failed to fire');
            },            

            test_DomEvent: function() {
                var pass = false;
                var handler = function() {
                    pass = true;
                };
                foo.on('click', handler);
                YAHOO.util.UserAction.click('foo');
                YAHOO.util.Assert.isTrue(pass, 'click handler failed to be called');
            },            

            test_customEvent: function() {
                var pass = false;
                var handler = function() {
                    pass = true;
                };
                foo.on('foo', handler);
                foo.fireEvent('foo');
                YAHOO.util.Assert.isTrue(pass, 'foo handler failed to be called');
            }
        })); 
        tool.TestRunner.add(suite);

        if (parent && parent != window) {
            tool.TestManager.load();
        } else {
            tool.TestRunner.run();
        }
    }); 
})();
</script>
<style type="text/css">

</style>
</head>
<body class="yui-skin-sam">
    <div id="doc">
        <div id="foo">foo</div>
    </div>
</body>
</html>
